Release 10.1A: OpenEdge Data Management:
SQL Reference


DISCONNECT

Terminates the connection between an application and the database to which it is connected.

Syntax

DISCONNECT { 'connection_name' | CURRENT | ALL | DEFAULT } ; 

connection_name

The name of the connection as either a character literal or host variable.

CURRENT

Disconnects the current connection.

ALL

Disconnects all established connections.

DEFAULT

Disconnects the connection to the default database.

Examples

The first example illustrates CONNECT TO AS connection_name and DISCONNECT connection_name:

EXEC SQL 
     CONNECT TO 'progress:T:localhost:6745:salesdb' AS 'conn_1' ; 
/* 
**  C Language and embedded SQL application processing against the 
**  database in the connect_string 
*/ 
   . 
   . 
   . 
EXEC SQL 
     DISCONNECT 'conn_1' ; 

This example illustrates CONNECT TO DEFAULT and DISCONNECT DEFAULT:

EXEC SQL 
    CONNECT TO DEFAULT ; 
/* 
**  C Language and embedded SQL application processing against the 
**  database in the connect_string 
*/ 
   . 
   . 
   . 
EXEC SQL 
    DISCONNECT DEFAULT ; 

This example disconnects all database connections. After you issue DISCONNECT ALL there is no current connection:

EXEC SQL 
     DISCONNECT ALL; 

The following example illustrates the CONNECT, SET CONNECTION, and DISCONNECT statements in combination using these steps:

1. CONNECT TO connect_string AS connection_name, which establishes a connect_string connection to the database in the connect_string; the connection has the name 'conn_1'.

2. CONNECT TO DEFAULT, which establishes a connection to the DEFAULT database and sets this connection current.

3. DISCONNECT DEFAULT, which disconnects the connection to the DEFAULT database.

4. SET CONNECTION connection_name, which sets the 'conn_1' connection current.

5. DISCONNECT CURRENT, which disconnects the 'conn_1' connection.

This example illustrates connection management statements in combination:

/* 
**  1. CONNECT TO 'connect_string' 
*/ 
EXEC SQL 
     CONNECT TO 'progress:T:localhost:6745:salesdb' AS 'conn_1' ; 
/* 
**  2. CONNECT TO DEFAULT. This suspends the conn_1 connection 
**     and sets the DEFAULT connection current 
*/ 
EXEC SQL 
     CONNECT TO DEFAULT ; 
/* 
** Application processing against the DEFAULT database 
*/ 
   . 
   . 
   . 
/* 
**  3. DISCONNECT DEFAULT 
*/ 
EXEC SQL 
     DISCONNECT DEFAULT ; 
/* 
**  4. Set the first connection, conn_1, current 
*/ 
EXEC SQL 
     SET CONNECTION conn_1 ; 
/* 
** Application processing against the database in the connect_string 
*/ 
   . 
   . 
   . 
/* 
**  5. DISCONNECT the conn_1 connection, which is the current connection. 
*/ 
EXEC SQL 
     DISCONNECT CURRENT ; 

Notes

Authorization

None

Related statements

CONNECT, SET CONNECTION


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095